<template>
  <div class="merchant alltable">
    <div class="tabbar">
      <div class="let">  
         <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.startday"
          value = 'yyyy-MM-dd'
          placeholder="请选择开始日期"
          style="width: 130px"
        ></DatePicker>&nbsp;
        <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.endday"
          placeholder="请选择结束日期"
          style="width: 130px"
        ></DatePicker>&nbsp; 
        <Button class="btn_default" @click="search">
          <Icon type="ios-search" size="17" class="icon_wy"/>查询
        </Button>
      </div>
      <!--   <div class='rit'>               
                <Button @click="add_merchant"><Icon type="ios-add-circle-outline" size="17" class="icon_wy"/>添加员工</Button>
      </div>-->
    </div>
    <div class="tabble">
      <div>
        <Table
          :columns="columns"
          :loading="loading"
          height="560"
         
          :data="data.datas"
          class="sel_table"
        ></Table>
      </div>
    </div>

    <div class="tab_pages">
       <div>
        <Table
          :show-header="false"
          :columns="columns1"
          :loading="loading"          
          :data="data.all"
          no-data-text = ""
          class="sel_table"
        ></Table>
      </div>
    </div>
  </div>
</template>
<script>
import { setAdmin, setToken, getAdmin } from "../../../utils/auth.js";
import { rechargeStatistics } from "../../../apis/api_system.js";
import filter from './../../../filters/filter';
export default {
  name: "rech_statis",
  data() {
    return {
      userId: "",
      model1: "",
      value: "",
      data: {
        all:[],
        allCount: 0,
        currPage: 1,
        datas: [],        
      },
      data_axios: {
        startday: "",
        endday: "",        
      },
      loading: false,      
      Mnamelist: [],      
      typelist: [
        {
          mid: 0,
          cname: "收入"
        },
        {
          mid:1,
          cname: "结算"
        }
      ],
      columns: [
        {
          title: "序号",
          key: "name",
          type: "index",
          width: 100,
          align:'center'
        },
        {
          title: "日期",
          key: "day",  
           align:'center'                 
        },
        
        {
          title: "微信金额",
          key: "weixin",
         align:'center'
        },
        {
          title: "支付宝金额",
          key: "ali",
          align:'center'
        },
        
        {
          title: "其他金额 ",
          key: "other",   
         align:'center'      
        },
        {
          title: "金额 ",
          key: "paymentamt",
           align:'center'
        },
        {
          title: "条数",
          key: "count",
           align:'center'
        },        
      ],
       columns1: [
        {
          title: "序号",                  
          width: 100,
           align:'center',
          render: (h, params) => {
            const row = params.row;
            const text = '总计：';
            return <span>{text}</span>;
          }
        },
        {
          title: "日期",
          key: "",   
            align:'center'                
        },        
        {
          title: "微信金额",
          key: "weixin",
            align:'center'
        //   width: 100,
        },
        {
          title: "支付宝金额",
          key: "ali",
            align:'center'
          //  width: 100
        },        
        {
          title: "其他金额 ",
          key: "other",  
            align:'center' 
        //   width: 100,       
        },
        {
          title: "金额 ",
          key: "paymentamt",
            align:'center'
        },
        {
          title: "条数",
          key: "count",
            align:'center'
        },        
      ],
    };
  },
  
  mounted() {    
    let info = getAdmin();
    this.userId = info.id;
    // console.log(this.userId);
    // this.selectMname();
    // this.rechargeStatistics(this.data_axios);
  },
  methods: { 
    //   获取商户交易明细
    rechargeStatistics(info) { 
      this.loading = true;      
       if(this.data_axios.startday!=''){
          this.data_axios.startday =  filter.FileterDate(this.data_axios.startday);
       }
       if(this.data_axios.endday!=''){
          this.data_axios.endday =  filter.FileterDate(this.data_axios.endday);
       }      
      let data = JSON.stringify({
        requestString: JSON.stringify(info),
        userId: this.userId,
        fullname: "充值统计"
      });
      rechargeStatistics(data)
        .then(({ returnString, code, disp ,count}) => {            
          this.loading = false;
          console.log(JSON.parse(returnString));
          var data_info = JSON.parse(returnString);  
          this.data =   data_info;                  
          console.log(this.data)      
          if (code == 200) {
            this.data.datas = data_info.list;
            console.log(this.data.datas);                    
          } else {            
            this.$Message.warning(disp);
          }
        })
        .catch(err => {});
    },   
    //分页改变
    merchant_data() {
       this.rechargeStatistics(this.data_axios);
    },
    //   搜索
    search() { 
      this.rechargeStatistics(this.data_axios);
    },    
  }
};
</script>